<!-- 设备详情弹窗 -->
<template>
  <a-form
    ref="form3"
    class="ele-form-detail"
    :model="deviceModalApp.device"
    :label-col="{md: {span: 2}, sm: {span: 4}, xs: {span: 6}}"
    :wrapper-col="{md: {span: 22}, sm: {span: 20}, xs: {span: 18}}">
    <a-descriptions :title="deviceModalApp.title" bordered>
<!--      <a-descriptions-item label="标识">-->
<!--        {{ deviceModalApp.device.Eid }}-->
<!--      </a-descriptions-item>-->
<!--      <a-descriptions-item label="创建人">-->
<!--        {{ deviceModalApp.device.creatorName }}-->
<!--      </a-descriptions-item>-->
<!--      <a-descriptions-item label="名称">-->
<!--        {{ deviceModalApp.device.name }}-->
<!--      </a-descriptions-item>-->
      <a-descriptions-item label="设备编号">
        {{ deviceModalApp.device.deviceCode }}
      </a-descriptions-item>
      <a-descriptions-item label="设备型号">
        {{ deviceModalApp.device.model }}
      </a-descriptions-item>
      <a-descriptions-item label="设备类型">
        {{ deviceModalApp.device.type }}
      </a-descriptions-item>
      <a-descriptions-item label="购入日期">
        {{ deviceModalApp.device.purchaseDate }}
      </a-descriptions-item>
      <a-descriptions-item label="使用日期">
        {{ deviceModalApp.device.useDate }}
      </a-descriptions-item>
      <a-descriptions-item label="制造单位">
        {{ deviceModalApp.device.manufacturer }}
      </a-descriptions-item>
      <a-descriptions-item label="使用单位">
        {{ deviceModalApp.device.useOrganization }}
      </a-descriptions-item>
      <a-descriptions-item label="设备位置">
        {{ deviceModalApp.device.location }}
      </a-descriptions-item>
      <a-descriptions-item label="设备区域">
        {{ deviceModalApp.device.area }}
      </a-descriptions-item>
      <a-descriptions-item label="设备图片">
        {{ deviceModalApp.device.img }}
      </a-descriptions-item>
      <a-descriptions-item label="二维码">
        {{ deviceModalApp.device.qrCode }}
      </a-descriptions-item>
      <a-descriptions-item label="状态">
        {{ deviceModalApp.device.status }}
      </a-descriptions-item>
<!--      <a-descriptions-item label="创建人ID">-->
<!--        {{ deviceModalApp.device.creatorId }}-->
<!--      </a-descriptions-item>-->
      <a-descriptions-item label="备注">
        {{ deviceModalApp.device.remark }}
      </a-descriptions-item>
      <a-descriptions-item label="创建时间">
        {{ deviceModalApp.device.createDatetime }}
      </a-descriptions-item>
    </a-descriptions>
  </a-form>
</template>

<script>
import {defineComponent, reactive, onMounted, inject} from "vue";
import {useRoute} from "vue-router"
import {DeviceService} from "@/views/repair/repairManagement/device/deviceService";

export default defineComponent({
  setup() {
    const route = useRoute();
    let routeId = route.params.id;
    let deviceListApp = inject('deviceListApp', reactive({}));
    const deviceModalApp = reactive({id: null, device: {}, display: false});

    onMounted(() => {
      deviceModalApp.device = {};
      if (routeId) {
        deviceModalApp.id = routeId;
      } else if (deviceListApp.viewModalShowing) {
        deviceModalApp.id = deviceListApp.currentId;
        deviceModalApp.display = true;
      }
      if (deviceModalApp.id) {
        getInfo(deviceModalApp.id);
      }
    })

    const getInfo = (id) => {
      DeviceService.findDevice(id).then((res) => {
        deviceModalApp.device = res.data;
        deviceModalApp.title = "查看 " + deviceModalApp.device.name;
      })
    }

    return {
      deviceModalApp,
      routeId,
      getInfo,
    }
  }
})
</script>

<style scoped>
</style>

